#include "ExitGameUI.h"
#include "DialogManager.h"

ExitGameUI::ExitGameUI() : IDialog()
{
    RegDialogCtrl("Button_Close", m_close);
    RegDialogCtrl("Button_Exit", m_click);
}

ExitGameUI::~ExitGameUI(){
    SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
}

void ExitGameUI::onUILoaded() {
    m_rootNode->setScale(0.9f);
    m_rootNode->runAction(EaseElasticOut::create(ScaleTo::create(0.2f, 1.0f))); //动画
    this->m_click->addClickEventListener([this](Ref* sender) {
        Director::getInstance()->end();
        exit(0);
    });
    this->m_close->addClickEventListener([this](Ref* sender) {
        DialogManager::shared()->closeCurrentDialog();
    });
    this->m_click->setTitleText("");
    this->m_close->setTitleText("");
    SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
}

